home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-26 | 43.0 KB | 1,311 lines | [TEXT/KEEN] |
- **************** Indent User’s Manual *******************
- Copyright © 1997 the Free Software Foundation, Inc. You can
- redistribute or modify this file under the terms of the GNU General
- Public License as published by the Free Software Foundation (see
- the file “COPYING Indent”). font: Geneva 12. Four spaces per tab.
-
- This manual is based on "indent.info" as supplied with the
- original version of "indent", specifically Edition 1.3, January 1994
- for indent Version 1.9.
-
- "Indent" is a Drag_on Module, based on the MPW tool version of
- "indent" which is widely available (eg at Info-Mac). Indent must be
- called by some application, and interaction between Indent and the
- application will vary according to how well the calling app
- supports text documents. However, virtually any (C or C++ based)
- application can add the ability to call Indent. For details you can
- model your approach after the section "Calling hAWK from your
- application" in the "hAWK User's Manual", which accompanies
- EnterAct (free, available at Info-Mac and on the Apprentice CD).
-
- Application which support Indent:
- Minimal App, EnterAct, RFEdit.
-
- Major topics are marked with MPW-compatible marks, available in
- many editors by holding down the <Option> or <Command> key while
- clicking in the window’s title bar. You can jump to a section
- heading by selecting the heading in the table of contents and using
- the editor’s “Enter Selection”/“Find Again” commands.
-
- Ya but what is it? Indent changes the appearance of a C or C++
- program by altering whitespace in accordance with a
- particular "style" or collection of options. There are many many
- options, and you will find it a bit of a drag to create up your own
- set of fine-tuned options to suit your exact needs. However, Indent
- does come equipped with some "canned" collections of options
- (called "profiles") and you may find that one of them is good
- enough.
-
- Indent is not, alas, recommended for use with Java.
-
- Introduction
- ------------
- Indent is what they used to call in the old days a "pretty printer",
- altering the spaces, tabs, and carriage returns in your source code
- to match your preferred style (or at least come close). This
- version differs from the MPW tool version in that it supports
- C++ (not perfectly, but often good enough) and it has
- a dialog interface that allows you to run Indent on one or more
- source files with a specific style by clicking the mouse a time
- or three. You can also invoke Indent the old-fashioned way with
- a command line.
-
- Indent uses the concept of standard input, output, and error, but
- strictly in the form of files with the fixed names $tempStdIn,
- $tempStdOut, and $tempStdErr. These files are created and written
- to as needed, and can be found in the same folder that contains
- your “Drag_on Modules” folder after you’ ve begun running Indent
- programs. These are temporary files, and will normally be
- overwritten by each Indent program run.
-
- At present Indent runs only in "immediate" mode, meaning that
- your machine is tied up until Indent finishes or you cancel
- with a <command><period>. However, it's pretty quick.
-
-
- Installation
- ------------
- As typically shipped, Indent goes inside your "Drag_on Modules"
- folder, and this folder should be in the same folder that contains
- the calling application, at the same level. The "Indent profiles"
- folder should also be in the "Drag_on Modules" folder, and this
- manual can go anywhere.
-
- To verify that Indent has been installed, start up an application
- that can call Indent and then check the menus; you should see
- “Indent” as one of the items.
-
- Running Indent programs
- -----------------------
- Introduction
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Indent "setup" dialog appears when you select Indent from the
- calling application's menus. Note if you have selected a
- command line beforehand then the dialog will be skipped and Indent
- will go straight to the job. Using the dialog rather than bothering
- with command lines is the simplest approach to using Indent.
-
- Once the dialog appears, you can persuade Indent to do something
- with the following four steps:
- • select your preferred "Style" from the top menu (much more
- on styles later, a "style" is a text file containing a list
- of Indent options)
- • use the "Input" popup menu to select your preferred input
- • get your desired output option with the bottom popup
- • and click "Run".
-
- Now we'll look at the three popups in turn.
-
- The Style menu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- The exact "style" used to set your whitespace is determined by
- many options. Rather than having a monstrous dialog with 87 check
- boxes and edit fields, Indent takes a complete list of desired
- options from a text file. The "profile" files supplied with Indent
- can be found in the "Indent profiles" folder, and each one consists
- of a list of rather cryptic "command line" style options, which are
- spelled out below in the "Indent options" chapter. Once you have a
- style you like, you can save it as a profile and then it will appear
- in the "Style" menu.
-
- The first three styles, GNU, K&R and Bekeley, are the original
- "canned" profiles shipped with earlier versions of Indent. You
- will probably prefer to use one of the Macintosh-adjusted versions
- supplied with this version of Indent, the ".pro" names appearing
- at the bottom of the Style menu in the above illustration.
-
- But to do better you will need to browse through all of the options
- described in the "Indent options" chapter below and come up with
- your own ".pro" file.
-
- The Input menu
-
-
-
-
-
-
-
-
-
-
-
-
-
- The Input menu for Indent presents the same options as offered
- with hAWK.
-
- The options “Front text selection” and “All of front text” refer to
- the text window that happens to be in front just before you call
- Indent from the calling app’s menu. According to what you select
- here, all or just the selected part of the text in the front window
- will be written to a temporary file called “$tempStdIn”, and
- passed to your program as the input file to use. If your program is
- to be run using one of these options, bring the text window
- containing the text to be used as input to the front just before
- calling Indent, and if you’ll be using the “Front text selection”
- option, you should select the text as well.
-
- The “MFS selected files” option in the Input popup refers to a list
- of files selected in the calling application for multi–file
- operations (typically this list is used mainly for multi–file
- searching in the calling application, and you construct it by
- placing check marks or bullets • beside file names—see the calling
- app’s manual for details). With this option selected, all files
- selected for multi–file operations will be passed to the Indent
- program as input. This means you can set up a list of files in the
- calling app, and then have Indent take its input from those files,
- from one file to hundreds.
-
- The “Select input file…” option allows you to use a standard Open
- dialog to pick one specific file to use as input for Indent.
-
- Aside from “Select input file…”, input options will not be shown if
- they are not currently available.
-
- That being said, the allowable output options depend critically
- on your choice of input, as told next.
-
- The Output menu
-
-
-
-
-
-
-
-
-
-
-
-
-
- The illustration shows the full range of output options, which
- is only available when you use the "Select input file..." option
- to pick one file for input.
-
- "Back up and overwrite" will replace your input file(s) with the
- restyled version, but before doing that it will create a backup copy
- of the original in the same folder. The name of the backup file will
- contain a version number. Quoting from the full description of
- Indent's inner workings below: Numbered backup versions of a file
- `momewraths' look like `momewraths.c.~23~', where 23 is the
- version of this particular backup. When making a numbered backup
- of the file `:src:momewrath.c', the backup file will be named
- `:src:momewrath.c.~V~', where V is one greater than the highest
- version currently existing in the directory `src'. This option is
- available if you have chosen MFS files or one specific file as input.
-
- "Rename with number" will leave your original file intact, and
- write the restyled version to a file whose name is the original
- name but with a version number appended just before the file
- extension, eg "File.cp" will be restyled as "File~1.cp", "File~1.cp"
- as "File~2.cp" etc, again in the same folder as the original. This
- option is available only if you chose one specific file for input
- using the "Select input file..." input option.
-
- "To $tempStdOut" will write all output to the $tempStdOut file,
- a file which is also used for output by hAWK, so the results
- there will be temporary. The calling application will (probably)
- show you this file after Indent is done. This option is available
- for one specific input file, and also if you have selected all
- or part of the front file for input.
-
- Creating Indent profiles
- ------------------------
- This would all be trivial if you just had a style in the can that
- you liked, wouldn't it?
-
- Your best approach to creating your preferred ".pro" file is to try
- out the supplied styles until you find one that's close to your ideal
- (use "Select input file...." with the "Rename with number" output
- option to avoid altering any original file just yet). Then cruise
- through the detailed options below to find the ones you need
- to change to make your profile perfect.
-
- To create your own Indent profile:
- • it must be a TEXT file with name ending in ".pro"
- • for easiest access, place it in your "Indent profiles" folder
- • in the file, put a complete list of options describing your
- preferred style.
-
- If you place your profile in your "Indent profiles" folder,
- then it will appear in Indent's "Style" popup.
-
- For example, here is the complete "macGNU.pro" style:
-
- -nbad -bap -nbc -bl -bli2 -c50 -cd50 -ncdb -nce -cli0
- -cp1 -di2 -nfc1 -nfca -i2 -ip5 -lp -npcs -psl -cs
- -nsc -nsob -nss -d0 -ci0 -l84 -ts4
-
- Whatever style you create, you should include these options:
- • -npcs ( --no-space-after-function-call-names): Indent is
- a bit dumb about some things, best to suppress spaces after
- procedure names, otherwise it will put spaces after macro
- name too (ouch).
- • -ts4 (4 spaces per tab): unless your files typically contain
- some other number of spaces per tab, put this option in.
- Without it, the default is 8 spaces per tab.
- • -l84 (maximum line length 84 characters): the default is
- 78 characters, yer author prefers 84 but somewhere between
- 75 and 86 is what you will want.
-
- For all the gory details, please see the "Indent options" chapter
- below.
-
- However if you want to take a quick and dirty approach you can
- listen in now as I quickly go through all the important options
- while trying to approximate my own preferred style, which
- resembles the standard GNU style:
-
- -bad : blank line after block of decls: YES
- -bap : blank line after every procedure body: YES
- -sob : swallow extra blank lines: NO, use -nsob
-
- -faa, -fc1 : format comments, NO leave them out
- -lN : maximum line length, use -l84
- -lcN : comment line length, NO (-l84 will apply)
- -dN : unident comment by: NO, use -d0 (zero)
- -c40, -cd40,-cp40 for trailing comment positions
- -cdb : comment delim on separate line: NO, -ncdb
- -sc : stars at beginnings of comment lines: NO, leave it out
-
- -br (right) vs -bl : I like bl (brace under if () on new line),
- if you want '{' on same line as "if" then use -br
- -bliN : Indent braces N spaces, use -bli0 (none)
- -ce : cuddle else : NO, use -nce
- -cli : use -cli0 (zero) to indent case labels
- -ss : no big deal, use it
- -pcs : blank after procedure name : NO, use -npcs
- (otherwise macro names get space after too)
- -cs : space after cast: NO, leave it out
- -bs : no big deal, leave it out
-
- -di : identifier indent: hmmm, try -di16
- -bc : newline after each comma in decl: YES
- -psl : function return type on separate line: NO, use -npsl
- -tsN : tab stop in input/output, use -ts4
- -iN : indentation level: use -i4 (one tab in)
- -ciN : continued statement indent: use -ci4
- -lp : indent after left paren: YES
- -ip : old-style decl indent, no big deal use -ip4
- -T : if using EnterAct, these not needed.
-
- My approximate style, in summary:
- -bad -bap -nsob -l84 -d0 -c40 -cd40 -cp40 -ncdb -bl -bli0 -nce
- -cli0 -ss -npcs -di16 -bc -npsl -ts4 -i4 -ci4 -lp -ip4 -eei4
-
- (saved as "Ken.pro" in the "Indent profiles" folder)
-
- Mystery options:
- -eei : extra expression indent, not sure yet what it does....
-
- Calling Indent with a command line
- ----------------------------------
- Your calling application's manual should also have details on
- how to call Indent using a command line. This manual just
- deals with what can appear on a command line, not how you
- instruct your application to treat it as a command line.
-
- A typical command line to invoke Indent looks like
- Indent "macBerkeley.pro"
- "Atlas:CW CEDAR:Indent test files:FindScreen.c"
- -o "Atlas:CW CEDAR:Indent test files:FindScreen1.c"
- (well actually that was three lines, but that should be OK
- with your calling application)
-
- After the name "Indent" itself, you specify a ".pro" file
- to use for the style options, one or more input files,
- and then the output.
-
- Here are the rules for cooking up a command line:
- • the command line should start with "Indent" followed
- by at least one space.
- • with more than one input file your only output option is
- the equivalent of "Back up and overwrite". This is the
- default behaviour, and there is no way to explicitly
- specify it.
- • no "standard input" options are available, in particular
- you can't take input from part of all of the front file
- (anyway, the front file is typically the one you type the
- command line in)
- • the "Rename with number" option is not available. Instead
- you can explicitly give a name to the restyled version by
- using "-o" followed by the new name. This renaming option
- is only valid if you explictly specify exactly one file for
- input.
- • to use the calling application's multi-file selection for
- input, place "MFS" or "-MFS" on the command line. With
- this option you cannot specify naming options for the
- output files, "Back up and overwrite" is always used.
- • if input is from one file you may specify output to
- "$tempStdOut" by using the option "-st".
- • quotes around file names (including profile names) are
- needed only if the path name or file name contains spaces.
- • if you specify a profile from your "Indent profiles" folder
- you don't need to include the full path. Otherwise, you do.
- • all explicitly named input and output files should have
- full path names.
- • since the full path names can make the command line
- quite long, your calling app will probably allow you to
- split the command line over several actual lines.
-
- The command line that's most useful is
- Indent myProfile.pro -MFS
- which will read options from the profile "myProfile.pro" in
- your "Indent profiles" folder (supply a real profile name there)
- and crank away on all files selected for multi-file operations
- in the calling app, making backups and overwriting the files
- with restyled versions.
-
- Come to think of it, that's probably the only useful one.
-
- No doubt you're aching to know what all the options are,
- so away we go....
-
- Indent options
- --------------
- (Following text is borrowed from the original "indent.info"
- manual that ships with the MPW version of Indent. Some minor
- changes have been made, mainly removal of unixisms.)
-
- Backup Files
- ============
-
- As of version 1.3, GNU `indent' makes GNU-style backup files,
- the same way GNU Emacs does. This means that either "simple"
- or "numbered" backup filenames may be made.
-
- Simple backup file names are generated by appending a suffix to
- the original file name. The default for the this suffix is the
- one-character string `~' (tilde). Thus, the backup file for
- `python.c' would be `python.c~'.
-
- Instead of the default, you may specify any string as a suffix by
- setting the environment variable `SIMPLE_BACKUP_SUFFIX' to
- your preferred suffix.
-
- Numbered backup versions of a file `momewraths' look like
- `momewraths.c.~23~', where 23 is the version of this particular
- backup. When making a numbered backup of the file
- `:src:momewrath.c', the backup file will be named
- `:src:momewrath.c.~V~', where V is one greater than the highest
- version currently existing in the directory `src'.
-
- The type of backup file made is controlled by the value of the
- environment variable `VERSION_CONTROL'. If it is the string
- `simple', then only simple backups will be made. If its value is
- the string `numbered', then numbered backups will be made. If
- its value is `numbered-existing', then numbered backups will be
- made if there *already exist* numbered backups for the file
- being indented; otherwise, a simple backup is made. If
- `VERSION_CONTROL' is not set, then `indent' assumes the
- behaviour of `numbered-existing'.
-
- Other versions of `indent' use the suffix `.BAK' in naming backup
- files. This behaviour can be emulated by setting
- `SIMPLE_BACKUP_SUFFIX' to `.BAK'.
-
- Note also that other versions of `indent' make backups in the
- current directory, rather than in the directory of the source file
- as GNU `indent' now does.
-
- Common styles
- =============
-
- There are several common styles of C code, including the GNU
- style, the Kernighan & Ritchie style, and the original Berkeley
- style. A style may be selected with a single "background" option,
- which specifies a set of values for all other options. However,
- explicitly specified options always override options implied by
- a background option.
-
- As of version 1.2, the default style of GNU `indent' is the GNU
- style. Thus, it is no longer neccessary to specify the option
- `-gnu' to obtain this format, although doing so will not cause an
- error. Option settings which correspond to the GNU style are:
-
- -nbad -bap -nbc -bl -bli2 -c33 -cd33 -ncdb -nce -cli0
- -cp1 -di2 -nfc1 -nfca -i2 -ip5 -lp -pcs -psl -cs
- -nsc -nsob -nss -ts8 -d0 -ci0 -l78
-
- The GNU coding style is that preferred by the GNU project. It is
- the style that the GNU Emacs C mode encourages and which is
- used in the C portions of GNU Emacs. (People interested in
- writing programs for Project GNU should get a copy of `The GNU
- Coding Standards', which also covers semantic and portability
- issues such as memory usage, the size of integers, etc.)
-
- The Kernighan & Ritchie style is used throughout their
- well-known book `The C Programming Language'. It is enabled
- with the `-kr' option. The Kernighan & Ritchie style corresponds
- to the following set of options:
-
- -nbad -bap -nbc -br -c33 -cd33 -ncdb -ce -ci4
- -cli0 -cp33 -d0 -di1 -nfc1 -nfca -i4 -ip0 -l75 -lp
- -npcs -npsl -nsc -nsob -nss -ts8 -cs
-
- Kernighan & Ritchie style does not put comments to the right of
- code in the same column at all times (nor does it use only one
- space to the right of the code), so for this style `indent' has
- arbitrarily chosen column 33.
-
- The style of the original Berkeley `indent' may be obtained by
- specifying `-orig' (or by specifyfying `--original', using the long
- option name). This style is equivalent to the following settings:
-
- -nbap -nbad -bc -br -c33 -cd33 -cdb -ce -ci4
- -cli0 -cp33 -d4 -di16 -fc1 -fca -i4 -ip4 -l75 -lp
- -npcs -psl -sc -nsob -nss -ts8 -ncs
-
- Blank lines
- ===========
-
- Various programming styles use blank lines in different places.
- `indent' has a number of options to insert or delete blank lines in
- specific places.
-
- The `-bad' option causes `indent' to force a blank line after every
- block of declarations. The `-nbad' option causes `indent' not to
- force such blank lines.
-
- The `-bap' option forces a blank line after every procedure body.
- The `-nbap' option forces no such blank line.
-
- The `-sob' option causes `indent' to swallow optional blank lines
- (that is, any optional blank lines present in the input will be
- removed from the output). If the `-nsob' is specified, any blank
- lines present in the input file will be copied to the output file.
-
- -blank-lines-after-declarations
- -------------------------------
-
- The `-bad' option forces a blank line after every block of
- declarations. The `-nbad' option does not add any such blank lines.
-
- For example, given the input
- char *foo;
- char *bar;
- /* This separates blocks of declarations. */
- int baz;
-
- `indent -bad' produces
-
- char *foo;
- char *bar;
-
- /* This separates blocks of declarations. */
- int baz;
-
- and `indent -nbad' produces
-
- char *foo;
- char *bar;
- /* This separates blocks of declarations. */
- int baz;
-
- -blank-lines-after-procedures
- -----------------------------
-
- The `-bap' option forces a blank line after every procedure body.
-
- For example, given the input
-
- int
- foo ()
- {
- puts("Hi");
- }
- /* The procedure bar is even less interesting. */
- char *
- bar ()
- {
- puts("Hello");
- }
-
- `indent -bap' produces
-
- int
- foo ()
- {
- puts ("Hi");
- }
-
- /* The procedure bar is even less interesting. */
- char *
- bar ()
- {
- puts ("Hello");
- }
-
- and `indent -nbap' produces
-
- int
- foo ()
- {
- puts ("Hi");
- }
- /* The procedure bar is even less interesting. */
- char *
- bar ()
- {
- puts ("Hello");
- }
-
- No blank line will be added after the procedure `foo'.
-
- Comments
- ========
-
- `indent' formats both C and C++ comments. C comments are
- begun with `/*' and terminated with `*/' and may contain
- newline characters. C++ comments begin with the delimiter `//'
- and end at the newline.
-
- `indent' handles comments differently depending upon their
- context. `indent' attempts to distinguish amongst comments
- which follow statements, comments which follow declarations,
- comments following preprocessor directives, and comments
- which are not preceded by code of any sort, i.e., they begin the
- text of the line (although not neccessarily in column 1).
-
- `indent' further attempts to leave "boxed comments" unmodified.
- The general idea of such a comment is that it is enclosed in a
- rectangle or "box" of stars or dashes to visually set it apart.
- More precisely, boxed comments are defined as those in which
- the initial `/*' is followed immediately by the character `*', `=',
- `_', or `-', or those in which the beginning comment delimiter
- (`/*') is on a line by itself, and the following line begins with a
- `*' in the same column as the star of the opening delimiter.
-
- Examples of boxed comments are:
-
- /**********************
- * Comment in a box!! *
- **********************/
-
- /*
- * A different kind of scent,
- * for a different kind of comment.
- */
-
- `indent' attempts to leave boxed comments exactly as they are
- found in the source file. Thus the indentation of the comment is
- unchanged, and its length is not checked in any way. The only
- alteration made is that an embedded tab character may be
- converted into the appropriate number of spaces.
-
- Comments which are not boxed may be formatted, which means
- that the line is broken to fit within a right margin and
- left-filled with whitespace. Single newlines are equivalent to a
- space, but blank lines (two or more newlines in a row) are taken
- to mean a paragraph break. Formatting of comments which begin
- after the first column is enabled with the `-fca' option. To
- format those beginning in column one, specify `-fc1'. Such
- formatting is disabled by default.
-
- The right margin for formatting defaults to 78, but may be
- changed with the `-lc' or the `-l' option. `-l' specifies the right
- margin for all code, and `-lc' specifies the margin for only for
- comments. If `-l' is used alone, comments will be formatted
- according to the margin specified with that option.
-
- If the margin specified does not allow the comment to be
- printed, the margin will be automatically extended for the
- duration of that comment. The margin is not respected if the
- comment is not being formatted.
-
- If the comment begins a line (i.e., there is no program text to its
- left), it will be indented to the column it was found in unless
- the comment is within a block of code. In that case, such a
- comment will be aligned with the indented code of that block.
- This alignment may be affected by the `-d' option, which
- specifies an amount by which such comments are moved to the
- *left*, or unindented. For example, `-d2' places comments two
- spaces to the left of code. By default, comments are aligned
- with code.
-
- Comments to the right of code will appear by default in column
- 33. This may be changed with one of three options. `-c' will
- specify the column for comments following code, `-cd' specifies
- the column for comments following declarations, and `-cp'
- specifies the column for comments following preprocessor
- directives `#else' and `#endif'.
-
- If the code to the left of the comment exceeds the beginning
- column, the comment column will be extended to the next
- tabstop column past the end of the code, or in the case of
- preprocessor directives, to one space past the end of the
- directive. This extension lasts only for the output of that
- particular comment.
-
- The `-cdb' option places the comment delimiters on blank lines.
- Thus, a single line comment like `/* Claustrophobia */' can be
- transformed into:
-
- /*
- Claustrophobia
- */
-
- Stars can be placed at the beginning of multi-line comments
- with the `-sc' option. Thus, the single-line comment above can
- be transformed (with `-cdb -sc') into:
-
- /*
- * Claustrophobia
- */
-
- Statements
- ==========
-
- The `-br' or `-bl' option specifies how to format braces.
-
- The `-br' option formats statement braces like this:
-
- if (x > 0) {
- x--;
- }
-
- The `-bl' option formats them like this:
-
- if (x > 0)
- {
- x--;
- }
-
- These options also affect structure and enumeration
- declarations. The `-br' option produces structure declarations
- like the following:
-
- struct Sname {
- int i;
- char chp;
- } Vname;
-
- The default behaviour, also obtained by specifying `-bl', would
- yield the following format for the same declaration:
-
- struct Sname
- {
- int i;
- char chp;
- }
- Vname;
-
- If you use the `-bl' option, you may also want to specify the
- `-bli' option. This option specifies the number of spaces by
- which braces are indented. `-bli2', the default, gives the result
- shown above. `-bli0' results in the following:
-
- if (x > 0)
- {
- x--;
- }
-
- If you are using the `-br' option, you probably want to also use
- the `-ce' option. This causes the `else' in an if-then-else
- construct to cuddle up to the immediately preceding `}'. For
- example, with `-br -ce' you get the following:
-
- if (x > 0) {
- x--;
- } else {
- fprintf (stderr, "...something wrong?\n");
- }
-
- With `-br -nce' that code would appear as
-
- if (x > 0) {
- x--;
- }
- else {
- fprintf (stderr, "...something wrong?\n");
- }
-
- The `-cli' option specifies the number of spaces that case labels
- should be indented to the right of the containing `switch'
- statement.
-
- If a semicolon is on the same line as a `for' or `while' statement,
- the `-ss' option will cause a space to be placed before the
- semicolon. This emphasizes the semicolon, making it clear that
- the body of the `for' or `while' statement is an empty statement.
- `-nss' disables this feature.
-
- The `-pcs' option causes a space to be placed between the name
- of the procedure being called and the `(' (for example, `puts
- ("Hi");'. The `-npcs' option would give `puts("Hi");').
-
- If the `-cs' option is specified, `indent' puts a space after a cast
- operator.
-
- The `-bs' option ensures that there is a space between the
- keyword `sizeof' and its argument. In some versions, this is
- known as the `Bill_Shannon' option.
-
- Declarations
- ============
-
- By default `indent' will line up identifiers, in the column
- specified by the `-di' option. For example, `-di16' makes things
- look like:
-
- int foo;
- char *bar;
-
- Using a small value (such as one or two) for the `-di' option can
- be used to cause the indentifiers to be placed in the first
- available position, for example
-
- int foo;
- char *bar;
-
- The value given to the `-di' option will still affect variables
- which are put on separate lines from their types, for example
- `-di2' will lead to
-
- int
- foo;
-
- If the `-bc' option is specified, a newline is forced after each
- comma in a declaration. For example,
-
- int a,
- b,
- c;
-
- With the `-nbc' option this would look like
-
- int a, b, c;
-
- The `-psl' option causes the type of a procedure being defined to
- be placed on the line before the name of the procedure. This
- style is required for the `etags' program to work correctly, as
- well as some of the `c-mode' functions of Emacs.
-
- If you are not using the `-di1' option to place variables being
- declared immediately after their type, you need to use the `-T'
- option to tell `indent' the name of all the typenames in your
- program that are defined by `typedef'. `-T' can be specified more
- than once, and all names specified are used. For example, if your
- program contains
-
- typedef unsigned long CODE_ADDR;
- typedef enum {red, blue, green} COLOR;
-
- you would use the options `-T CODE_ADDR -T COLOR'.
-
- Indentation
- ===========
-
- One issue in the formatting of code is how far each line should
- be indented from the left margin. When the beginning of a
- statement such as `if' or `for' is encountered, the indentation
- level is increased by the value specified by the `-i' option. For
- example, use `-i8' to specify an eight character indentation for
- each level. When a statement is broken across two lines, the
- second line is indented by a number of additional spaces
- specified by the `-ci' option. `-ci' defaults to 0. However, if the
- `-lp' option is specified, and a line has a left parenthesis which
- is not closed on that line, then continuation lines will be lined
- up to start at the character position just after the left
- parenthesis. This processing also applies to `[' and applies to `{'
- when it occurs in initialization lists. For example, a piece of
- continued code might look like this with `-nlp -ci3' in effect:
-
- p1 = first_procedure (second_procedure (p2, p3),
- third_procedure (p4, p5));
-
- With `-lp' in effect the code looks somewhat clearer:
-
- p1 = first_procedure (second_procedure (p2, p3),
- third_procedure (p4, p5));
-
- `indent' assumes that tabs are placed at regular intervals of
- both input and output character streams. These intervals are by
- default 8 columns wide, but (as of version 1.2) may be changed
- by the `-ts' option. Tabs are treated as the equivalent number of
- spaces.
-
- The indentation of type declarations in old-style function
- definitions is controlled by the `-ip' parameter. This is a
- numeric parameter specifying how many spaces to indent type
- declarations. For example, the default `-ip5' makes definitions
- look like this:
-
- char *
- create_world (x, y, scale)
- int x;
- int y;
- float scale;
- {
- . . .
- }
-
- For compatibility with other versions of indent, the option `-nip'
- is provided, which is equivalent to `-ip0'.
-
- ASCII C allows white space to be placed on preprocessor
- command lines between the character `#' and the command name.
- By default, `indent' removes this space, but specifying the `-lps'
- option directs `indent' to leave this space unmodified.
-
- Disabling Formatting
- ====================
-
- Formatting of C code may be disabled for portions of a program
- by embedding special "control comments" in the program. To turn
- off formatting for a section of a program, place the disabling
- control comment `/* *INDENT-OFF* */' on a line by itself just
- before that section. Program text scanned after this control
- comment is output precisely as input with no modifications
- until the corresponding enabling comment is scanned on a line by
- itself. The disabling control comment is `/* *INDENT-ON* */',
- and any text following the comment on the line is also output
- unformatted. Formatting begins again with the input line
- following the enabling control comment.
-
- More precisely, `indent' does not attempt to verify the closing
- delimiter (`*/') for these C comments, and any whitespace on
- the line is totally transparent.
-
- These control comments also function in their C++ formats,
- namely
- `// *INDENT-OFF*' and `// *INDENT-ON*'.
-
- It should be noted that the internal state of `indent' remains
- unchanged over the course of the unformatted section. Thus, for
- example, turning off formatting in the middle of a function and
- continuing it after the end of the function may lead to bizarre
- results. It is therefore wise to be somewhat modular in
- selecting code to be left unformatted.
-
- As a historical note, some earlier versions of `indent' produced
- error messages beginning with `*INDENT**'. These versions of
- `indent' were written to ignore any input text lines which began
- with such error messages. I have removed this incestuous
- feature from `GNU indent'.
-
- Miscellaneous options
- =====================
-
- To find out what version of `indent' you have, use the command
- `indent -version'. This will report the version number of `indent',
- without doing any of the normal processing.
-
- The `-v' option can be used to turn on verbose mode. When in
- verbose mode, `indent' reports when it splits one line of input
- into two more more lines of output, and gives some size
- statistics at completion.
-
- Bugs
- ====
-
- The "-troff" option is strongly deprecated, and is not supported.
- A good thing for someone to do is to rewrite `indent' to generate
- TeX source as a hardcopy output option, amoung other things.
-
- Copyright
- =========
-
- The following copyright notice applies to the `indent' program.
- The copyright and copying permissions for this manual appear
- near the beginning of this document.
-
- Copyright (c) 1989, 1992 Free Software Foundation
- Copyright (c) 1985 Sun Microsystems, Inc.
- Copyright (c) 1980 The Regents of the University of California.
- Copyright (c) 1976 Board of Trustees of the University of Illinois.
- All rights reserved.
-
- Redistribution and use in source and binary forms are
- permitted provided that the above copyright notice and this
- paragraph are duplicated in all such forms and that any
- documentation, advertising materials, and other materials
- related to such distribution and use acknowledge that the
- software was developed by the University of California,
- Berkeley, the University of Illinois, Urbana, and Sun
- Microsystems, Inc. The name of either University or Sun
- Microsystems may not be used to endorse or promote products
- derived from this software without specific prior written
- permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND
- WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
- Option Summary
- **************
-
- Here is a list of all the options for `indent', alphabetized by
- short option. It is followed by a cross key alphabetized by long
- option.
-
- `-bad'
- `--blank-lines-after-declarations'
- Force blank lines after the declarations.
- *Note Blank lines::.
-
- `-bap'
- `--blank-lines-after-procedures'
- Force blank lines after procedure bodies.
- *Note Blank lines::.
-
- `-bbb'
- `--blank-lines-after-block-comments'
- Force blank lines after block comments.
- *Note Blank lines::.
-
- `-bc'
- `--blank-lines-after-commas'
- Force newline after comma in declaration.
- *Note Declarations::.
-
- `-bl'
- `--braces-after-if-line'
- Put braces on line after `if', etc.
- *Note Statements::.
-
- `-bliN'
- `--brace-indentN'
- Indent braces N spaces.
- *Note Statements::.
-
- `-br'
- `--braces-on-if-line'
- Put braces on line with `if', etc. and structure declarations
- *Note Statements::.
-
- `-cN'
- `--comment-indentationN'
- Put comments to the right of code in column N.
- *Note Comments::.
-
- `-cdN'
- `--declaration-comment-columnN'
- Put comments to the right of the declarations in column N.
- *Note Comments::.
-
- `-cdb'
- `--comment-delimiters-on-blank-lines'
- Put comment delimiters on blank lines.
- *Note Comments::.
-
- `-ce'
- `--cuddle-else'
- Cuddle else and preceeding `}'.
- *Note Comments::.
-
- `-ciN'
- `--continuation-indentationN'
- Continuation indent of N spaces.
- *Note Statements::.
-
- `-cliN'
- `--case-indentationN'
- Case label indent of N spaces.
- *Note Statements::.
-
- `-cpN'
- `--else-endif-columnN'
- Put comments to the right of `#else' and `#endif' statements in
- column N.
- *Note Comments::.
-
- `-cs'
- `--space-after-cast'
- Put a space after a cast operator.
- *Note Statements::.
-
- `-bs'
- `--blank-before-sizeof'
- Put a space between `sizeof' and its argument.
- *Note Statements::
-
- `-dN'
- `--line-comments-indentationN'
- Set indentation of comments not to the right of code to N spaces.
- *Note Comments::.
-
- `-diN'
- `--declaration-indentationN'
- Put variables in column N.
- *Note Declarations::.
-
- `-fc1'
- `--format-first-column-comments'
- Format comments in the first column.
- *Note Comments::.
-
- `-fca'
- `--format-all-comments'
- Do not disable all formatting of comments.
- *Note Comments::
-
- `-gnu'
- `--gnu-style'
- Use GNU coding style. This is the default.
- *Note Common styles::.
-
- `-iN'
- `--indent-levelN'
- Set indentation level to N spaces.
- *Note Indentation::.
-
- `-ipN'
- `--parameter-indentationN'
- Indent parameter types in old-style function definitions by N
- spaces.
- *Note Indentation::.
-
- `-kr'
- `--k-and-r-style'
- Use Kernighan & Ritchie coding style.
- *Note Common styles::.
-
- `-lN'
- `--line-lengthN'
- Set maximum line length to N.
- *Note Comments::.
-
- `-lcN'
- `--comment-line-lengthN'
- Set maximum line length for comment formatting to N.
- *Note Comments::.
-
- `-lp'
- `--continue-at-parentheses'
- Line up continued lines at parentheses.
- *Note Indentation::.
-
- `-lps'
- `--leave-preprocessor-space'
- Leave space between `#' and preprocessor directive. *Note
- Indentation::.
-
- `-nbad'
- `--no-blank-lines-after-declarations'
- Do not force blank lines after declarations.
- *Note Blank lines::.
-
- `-nbap'
- `--no-blank-lines-after-procedures'
- Do not force blank lines after procedure bodies.
- *Note Blank lines::.
-
- `-nbc'
- `--no-blank-lines-after-commas'
- Do not force newlines after commas in declarations.
- *Note Declarations::.
-
- `-ncdb'
- `--no-comment-delimiters-on-blank-lines'
- Do not put comment delimiters on blank lines.
- *Note Comments::.
-
- `-nce'
- `--dont-cuddle-else'
- Do not cuddle `}' and `else'.
- *Note Statements::.
-
- `-ncs'
- `--no-space-after-casts'
- Do not put a space after cast operators.
- *Note Statements::.
-
- `-nfc1'
- `--dont-format-first-column-comments'
- Do not format comments in the first column as normal.
- *Note Comments::.
-
- `-nfca'
- `--dont-format-comments'
- Do not format any comments.
- *Note Comments::.
-
- `-nip'
- `--no-parameter-indentation'
- Zero width indentation for parameters.
- *Note Indentation::
-
- `-nlp'
- `--dont-line-up-parentheses'
- Do not line up parentheses.
- *Note Statements::.
-
- `-npcs'
- `--no-space-after-function-call-names'
- Do not put space after the function in function calls.
- *Note Statements::.
-
- `-npsl'
- `--dont-break-procedure-type'
- Put the type of a procedure on the same line as its name.
- *Note Declarations::.
-
- `-nsc'
- `--dont-star-comments'
- Do not put the `*' character at the left of comments.
- *Note Comments::.
-
- `-nsob'
- `--leave-optional-blank-lines'
- Do not swallow optional blank lines.
- *Note Blank lines::.
-
- `-nss'
- `--dont-space-special-semicolon'
- Do not force a space before the semicolon after certain
- statements.
- Disables `-ss'.
- *Note Statements::.
-
- `-nv'
- `--no-verbosity'
- Disable verbose mode. *Note Miscellaneous options::.
-
- `-orig'
- `--original'
- Use the original Berkeley coding style.
- *Note Common styles::.
-
- `-npro'
- `--ignore-profile'
- Do not read `.indent.pro' files.
- *Note Invoking indent::.
-
- `-pcs'
- `--space-after-procedure-calls'
- Insert a space between the name of the procedure being
- called and the `('.
- *Note Statements::.
-
- `-psl'
- `--procnames-start-lines'
- Put the type of a procedure on the line before its name.
- *Note Declarations::.
-
- `-sc'
- `--start-left-side-of-comments'
- Put the `*' character at the left of comments.
- *Note Comments::.
-
- `-sob'
- `--swallow-optional-blank-lines'
- Swallow optional blank lines.
- *Note Blank lines::.
-
- `-ss'
- `--space-special-semicolon'
- On one-line `for' and `while' statments, force a blank before the
- semicolon.
- *Note Statements::.
-
- `-st'
- `--standard-output'
- Write to standard output.
- *Note Invoking indent::.
-
- `-T'
- Tell `indent' the name of typenames.
- *Note Declarations::.
-
- `-tsN'
- `--tab-sizeN'
- Set tab size to N spaces.
- *Note Indentation::.
-
- `-v'
- `--verbose'
- Enable verbose mode.
- *Note Miscellaneous options::.
-
- `-version'
- Output the version number of `indent'.
- *Note Miscellaneous options::.
-
- Options Cross Key
- ------------------
-
- Here is a list of options alphabetized by long option, to help you
- find the corresponding short option.
-
- --blank-lines-after-block-comments -bbb
- --blank-lines-after-commas -bc
- --blank-lines-after-declarations -bad
- --blank-lines-after-procedures -bap
- --braces-after-if-line -bl
- --brace-indent -bli
- --braces-on-if-line -br
- --case-indentation -cliN
- --comment-delimiters-on-blank-lines -cdb
- --comment-indentation -cN
- --continuation-indentation -ciN
- --continue-at-parentheses -lp
- --cuddle-else -ce
- --declaration-comment-column -cdN
- --declaration-indentation -diN
- --dont-break-procedure-type -npsl
- --dont-cuddle-else -nce
- --dont-format-comments -nfca
- --dont-format-first-column-comments -nfc1
- --dont-line-up-parentheses -nlp
- --dont-space-special-semicolon -nss
- --dont-star-comments -nsc
- --else-endif-column -cpN
- --format-all-comments -fca
- --format-first-column-comments -fc1
- --gnu-style -gnu
- --ignore-profile -npro
- --indent-level -iN
- --k-and-r-style -kr
- --leave-optional-blank-lines -nsob
- --leave-preprocessor-space -lps
- --line-comments-indentation -dN
- --line-length -lN
- --no-blank-lines-after-commas -nbc
- --no-blank-lines-after-declarations -nbad
- --no-blank-lines-after-procedures -nbap
- --no-comment-delimiters-on-blank-lines -ncdb
- --no-space-after-casts -ncs
- --no-parameter-indentation -nip
- --no-space-after-function-call-names -npcs
- --no-verbosity -nv
- --original -orig
- --parameter-indentation -ipN
- --procnames-start-lines -psl
- --space-after-cast -cs
- --space-after-procedure-calls -pcs
- --space-special-semicolon -ss
- --standard-output -st
- --start-left-side-of-comments -sc
- --swallow-optional-blank-lines -sob
- --tab-size -tsN
- --verbose -v
-
-